/**********************************************************************************************************
** 驱动文件：	ups-INVT33.c
** 驱动类型：	ups
** 设备名称：	UPS监测
** 设备型号：	INVT33
** 设备品牌：	英威腾
** 设备协议：	Modbus-RTU
** 驱动描述：	适用于英威腾三进三出UPS电源状态和报警监测。
** 生成日期：	2019-12-12 13:11:42
**********************************************************************************************************/
#include "Includes.h"


/**********************************************************************************************************
* 定义设备数据点变量结构
**********************************************************************************************************/
typedef struct{
	Var BypassUA;								//旁路A相电压
	Var BypassUB;								//旁路B相电压
	Var BypassUC;								//旁路C相电压
	Var BypassIA;								//旁路A相电流
	Var BypassIB;								//旁路B相电流
	Var BypassIC;								//旁路C相电流
	Var BypassFreqA;							//旁路A相频率
	Var BypassFreqB;							//旁路B相频率
	Var BypassFreqC;							//旁路C相频率
	Var BypassCOSA;								//旁路A相功率因数
	Var BypassCOSB;								//旁路B相功率因数
	Var BypassCOSC;								//旁路C相功率因数
	Var InputUA;								//输入A相电压
	Var InputUB;								//输入B相电压
	Var InputUC;								//输入C相电压
	Var InputIA;								//输入A相电流
	Var InputIB;								//输入B相电流
	Var InputIC;								//输入C相电流
	Var InputFreqA;								//输入A相频率
	Var InputFreqB;								//输入B相频率
	Var InputFreqC;								//输入C相频率
	Var InputCOSA;								//输入A相功率因数
	Var InputCOSB;								//输入B相功率因数
	Var InputCOSC;								//输入C相功率因数
	Var OutputUA;								//输出A相电压
	Var OutputUB;								//输出B相电压
	Var OutputUC;								//输出C相电压
	Var OutputIA;								//输出A相电流
	Var OutputIB;								//输出B相电流
	Var OutputIC;								//输出C相电流
	Var OutputFreqA;							//输出A相频率
	Var OutputFreqB;							//输出B相频率
	Var OutputFreqC;							//输出C相频率
	Var OutputCOSA;								//输出A相功率因数
	Var OutputCOSB;								//输出B相功率因数
	Var OutputCOSC;								//输出C相功率因数
	Var OutputSA;								//输出A相视在功率
	Var OutputSB;								//输出B相视在功率
	Var OutputSC;								//输出C相视在功率
	Var OutputPA;								//输出A相有功功率
	Var OutputPB;								//输出B相有功功率
	Var OutputPC;								//输出C相有功功率
	Var OutputQA;								//输出A相无功功率
	Var OutputQB;								//输出B相无功功率
	Var OutputQC;								//输出C相无功功率
	Var OutputLoadRateA;						//输出A相负载率
	Var OutputLoadRateB;						//输出B相负载率
	Var OutputLoadRateC;						//输出C相负载率
	Var AmbientTemperature;						//环境温度
	Var PositiveBatteryVoltage;					//正电池组电压
	Var NegativeBatteryVoltage;					//负电池组电压
	Var PositiveBatteryCurrent;					//正电池组电流
	Var NegativeBatteryCurrent;					//负电池组电流
	Var BatteryTemperature;						//电池温度
	Var BatteryRemainingTime;					//电池剩余时间
	Var BatteryCapacity;						//电池容量
	Var PowerSupplyMode;						//供电方式
	Var BatteryStatus;							//电池状态
	Var MaintenanceBypassAirSwitchStatus;		//维修旁路空开状态
	Var EPO;									//EPO
	Var InsufficientStartingCapacity;			//逆变器启动容量不足
	Var GeneratorJoin;							//发电机接入
	Var ACInputFailure;							//交流输入故障
	Var BypassPhaseSequenceFault;				//旁路相序故障
	Var BypassVoltageFailure;					//旁路电压故障
	Var BypassFailure;							//旁路故障
	Var BypassOverload;							//旁路过载
	Var BypassOverloadTimeout;					//旁路过载超时
	Var BypassOvertrack;						//旁路超跟踪
	Var SwitchTimesTo;							//切换次数到
	Var OutputShort;							//输出短路
	Var BatteryEOD;								//电池EOD
	Var BatterySelfCheckStatus;					//电池自检状态
	Var BatteryMaintenanceStatus;				//电池维护状态
	Var BatteryLowVoltage;						//电池低压
	Var ReverseBattery;							//电池反接
	Var RectifierStatus;						//整流器状态
	Var InputNLineDisconnected;					//输入N线断开
	Var BypassFanFailure;						//旁路风扇故障
	Var LossNXRedundancy;						//失去N+X冗余
	Var EODSystemInhibit;						//EOD系统禁止
	Var ModuleRectifierFailure;					//模块整流故障
	Var ModuleInverterFailure;					//模块逆变故障
	Var ModuleRectifierOverTemperature;			//模块整流过温
	Var ModuleFanFailure;						//模块风扇故障
	Var ModuleInverterOverload;					//模块逆变过载
	Var ModuleInversionOverTemperature;			//模块逆变过温
	Var ModuleInverterProtection;				//模块逆变保护
	Var ModuleManualShutdown;					//模块手动关机
}Data_Struct;									//定义变量结构


/**********************************************************************************************************
* 设备数据点变量属性声明
**********************************************************************************************************/
const static Var_Property_Def var_attr[] = {
	{
		FLOAT,
		0,
		READONLY,
		"BypassUA",
		"旁路A相电压",
		"V",
		"旁路A相电压",
		0,
		0,
		"旁路A相电压过高",
		"旁路A相电压过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"BypassUB",
		"旁路B相电压",
		"V",
		"旁路B相电压",
		0,
		0,
		"旁路B相电压过高",
		"旁路B相电压过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"BypassUC",
		"旁路C相电压",
		"V",
		"旁路C相电压",
		0,
		0,
		"旁路C相电压过高",
		"旁路C相电压过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"BypassIA",
		"旁路A相电流",
		"A",
		"旁路A相电流",
		0,
		0,
		"旁路A相电流过高",
		"旁路A相电流过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"BypassIB",
		"旁路B相电流",
		"A",
		"旁路B相电流",
		0,
		0,
		"旁路B相电流过高",
		"旁路B相电流过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"BypassIC",
		"旁路C相电流",
		"A",
		"旁路C相电流",
		0,
		0,
		"旁路C相电流过高",
		"旁路C相电流过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"BypassFreqA",
		"旁路A相频率",
		"Hz",
		"旁路A相频率",
		0,
		0,
		"旁路A相频率过高",
		"旁路A相频率过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"BypassFreqB",
		"旁路B相频率",
		"Hz",
		"旁路B相频率",
		0,
		0,
		"旁路B相频率过高",
		"旁路B相频率过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"BypassFreqC",
		"旁路C相频率",
		"Hz",
		"旁路C相频率",
		0,
		0,
		"旁路C相频率过高",
		"旁路C相频率过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"BypassCOSA",
		"旁路A相功率因数",
		"",
		"旁路A相功率因数",
		0,
		0,
		"旁路A相功率因数过高",
		"旁路A相功率因数过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"BypassCOSB",
		"旁路B相功率因数",
		"",
		"旁路B相功率因数",
		0,
		0,
		"旁路B相功率因数过高",
		"旁路B相功率因数过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"BypassCOSC",
		"旁路C相功率因数",
		"",
		"旁路C相功率因数",
		0,
		0,
		"旁路C相功率因数过高",
		"旁路C相功率因数过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"InputUA",
		"输入A相电压",
		"V",
		"输入A相电压",
		0,
		0,
		"输入A相电压过高",
		"输入A相电压过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"InputUB",
		"输入B相电压",
		"V",
		"输入B相电压",
		0,
		0,
		"输入B相电压过高",
		"输入B相电压过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"InputUC",
		"输入C相电压",
		"V",
		"输入C相电压",
		0,
		0,
		"输入C相电压过高",
		"输入C相电压过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"InputIA",
		"输入A相电流",
		"A",
		"输入A相电流",
		0,
		0,
		"输入A相电流过高",
		"输入A相电流过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"InputIB",
		"输入B相电流",
		"A",
		"输入B相电流",
		0,
		0,
		"输入B相电流过高",
		"输入B相电流过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"InputIC",
		"输入C相电流",
		"A",
		"输入C相电流",
		0,
		0,
		"输入C相电流过高",
		"输入C相电流过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"InputFreqA",
		"输入A相频率",
		"Hz",
		"输入A相频率",
		0,
		0,
		"输入A相频率过高",
		"输入A相频率过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"InputFreqB",
		"输入B相频率",
		"Hz",
		"输入B相频率",
		0,
		0,
		"输入B相频率过高",
		"输入B相频率过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"InputFreqC",
		"输入C相频率",
		"Hz",
		"输入C相频率",
		0,
		0,
		"输入C相频率过高",
		"输入C相频率过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"InputCOSA",
		"输入A相功率因数",
		"",
		"输入A相功率因数",
		0,
		0,
		"输入A相功率因数过高",
		"输入A相功率因数过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"InputCOSB",
		"输入B相功率因数",
		"",
		"输入B相功率因数",
		0,
		0,
		"输入B相功率因数过高",
		"输入B相功率因数过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"InputCOSC",
		"输入C相功率因数",
		"",
		"输入C相功率因数",
		0,
		0,
		"输入C相功率因数过高",
		"输入C相功率因数过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputUA",
		"输出A相电压",
		"V",
		"输出A相电压",
		0,
		0,
		"输出A相电压过高",
		"输出A相电压过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputUB",
		"输出B相电压",
		"V",
		"输出B相电压",
		0,
		0,
		"输出B相电压过高",
		"输出B相电压过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputUC",
		"输出C相电压",
		"V",
		"输出C相电压",
		0,
		0,
		"输出C相电压过高",
		"输出C相电压过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputIA",
		"输出A相电流",
		"A",
		"输出A相电流",
		0,
		0,
		"输出A相电流过高",
		"输出A相电流过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputIB",
		"输出B相电流",
		"A",
		"输出B相电流",
		0,
		0,
		"输出B相电流过高",
		"输出B相电流过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputIC",
		"输出C相电流",
		"A",
		"输出C相电流",
		0,
		0,
		"输出C相电流过高",
		"输出C相电流过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputFreqA",
		"输出A相频率",
		"Hz",
		"输出A相频率",
		0,
		0,
		"输出A相频率过高",
		"输出A相频率过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputFreqB",
		"输出B相频率",
		"Hz",
		"输出B相频率",
		0,
		0,
		"输出B相频率过高",
		"输出B相频率过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputFreqC",
		"输出C相频率",
		"Hz",
		"输出C相频率",
		0,
		0,
		"输出C相频率过高",
		"输出C相频率过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputCOSA",
		"输出A相功率因数",
		"",
		"输出A相功率因数",
		0,
		0,
		"输出A相功率因数过高",
		"输出A相功率因数过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputCOSB",
		"输出B相功率因数",
		"",
		"输出B相功率因数",
		0,
		0,
		"输出B相功率因数过高",
		"输出B相功率因数过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputCOSC",
		"输出C相功率因数",
		"",
		"输出C相功率因数",
		0,
		0,
		"输出C相功率因数过高",
		"输出C相功率因数过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputSA",
		"输出A相视在功率",
		"KVA",
		"输出A相视在功率",
		0,
		0,
		"输出A相视在功率过高",
		"输出A相视在功率过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputSB",
		"输出B相视在功率",
		"KVA",
		"输出B相视在功率",
		0,
		0,
		"输出B相视在功率过高",
		"输出B相视在功率过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputSC",
		"输出C相视在功率",
		"KVA",
		"输出C相视在功率",
		0,
		0,
		"输出C相视在功率过高",
		"输出C相视在功率过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputPA",
		"输出A相有功功率",
		"KW",
		"输出A相有功功率",
		0,
		0,
		"输出A相有功功率过高",
		"输出A相有功功率过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputPB",
		"输出B相有功功率",
		"KW",
		"输出B相有功功率",
		0,
		0,
		"输出B相有功功率过高",
		"输出B相有功功率过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputPC",
		"输出C相有功功率",
		"KW",
		"输出C相有功功率",
		0,
		0,
		"输出C相有功功率过高",
		"输出C相有功功率过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputQA",
		"输出A相无功功率",
		"KVar",
		"输出A相无功功率",
		0,
		0,
		"输出A相无功功率过高",
		"输出A相无功功率过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputQB",
		"输出B相无功功率",
		"KVar",
		"输出B相无功功率",
		0,
		0,
		"输出B相无功功率过高",
		"输出B相无功功率过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputQC",
		"输出C相无功功率",
		"KVar",
		"输出C相无功功率",
		0,
		0,
		"输出C相无功功率过高",
		"输出C相无功功率过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputLoadRateA",
		"输出A相负载率",
		"%",
		"输出A相负载率",
		0,
		0,
		"输出A相负载率过高",
		"输出A相负载率过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputLoadRateB",
		"输出B相负载率",
		"%",
		"输出B相负载率",
		0,
		0,
		"输出B相负载率过高",
		"输出B相负载率过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutputLoadRateC",
		"输出C相负载率",
		"%",
		"输出C相负载率",
		0,
		0,
		"输出C相负载率过高",
		"输出C相负载率过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"AmbientTemperature",
		"环境温度",
		"℃",
		"环境温度",
		0,
		0,
		"环境温度过高",
		"环境温度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"PositiveBatteryVoltage",
		"正电池组电压",
		"V",
		"正电池组电压",
		0,
		0,
		"正电池组电压过高",
		"正电池组电压过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"NegativeBatteryVoltage",
		"负电池组电压",
		"V",
		"负电池组电压",
		0,
		0,
		"负电池组电压过高",
		"负电池组电压过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"PositiveBatteryCurrent",
		"正电池组电流",
		"A",
		"正电池组电流",
		0,
		0,
		"正电池组电流过高",
		"正电池组电流过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"NegativeBatteryCurrent",
		"负电池组电流",
		"A",
		"负电池组电流",
		0,
		0,
		"负电池组电流过高",
		"负电池组电流过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"BatteryTemperature",
		"电池温度",
		"℃",
		"电池温度",
		0,
		0,
		"电池温度过高",
		"电池温度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"BatteryRemainingTime",
		"电池剩余时间",
		"分",
		"电池剩余时间",
		0,
		0,
		"电池剩余时间过高",
		"电池剩余时间过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"BatteryCapacity",
		"电池容量",
		"%",
		"电池容量",
		0,
		0,
		"电池容量过高",
		"电池容量过低",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"PowerSupplyMode",
		"供电方式",
		"",
		"供电方式：0-均不供电，1-UPS供电，2-旁路供电",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"BatteryStatus",
		"电池状态",
		"",
		"电池状态：0-电池未工作，1-电池浮充，2-电池均充，3-电池放电",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"MaintenanceBypassAirSwitchStatus",
		"维修旁路空开状态",
		"",
		"维修旁路空开状态：0-断开；1-闭合",
		0,
		0,
		"断开",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"EPO",
		"EPO",
		"",
		"EPO：0-无紧急关机，1-紧急关机",
		0,
		0,
		"紧急关机",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"InsufficientStartingCapacity",
		"逆变器启动容量不足",
		"",
		"逆变器启动容量不足：0-容量足够，1-容量不足",
		0,
		0,
		"容量不足",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"GeneratorJoin",
		"发电机接入",
		"",
		"发电机接入：0-断开，1-接入",
		0,
		0,
		"接入",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ACInputFailure",
		"交流输入故障",
		"",
		"交流输入故障：0-正常，1-故障",
		0,
		0,
		"故障",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"BypassPhaseSequenceFault",
		"旁路相序故障",
		"",
		"旁路相序故障：0-正常，1-故障",
		0,
		0,
		"故障",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"BypassVoltageFailure",
		"旁路电压故障",
		"",
		"旁路电压故障：0-正常，1-故障",
		0,
		0,
		"故障",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"BypassFailure",
		"旁路故障",
		"",
		"旁路故障：0-正常，1-故障",
		0,
		0,
		"故障",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"BypassOverload",
		"旁路过载",
		"",
		"旁路过载：0-正常，1-过载",
		0,
		0,
		"过载",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"BypassOverloadTimeout",
		"旁路过载超时",
		"",
		"旁路过载超时：0-正常，1-过载超时",
		0,
		0,
		"过载超时",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"BypassOvertrack",
		"旁路超跟踪",
		"",
		"旁路超跟踪：0-正常，1-旁路超跟踪",
		0,
		0,
		"旁路超跟踪",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"SwitchTimesTo",
		"切换次数到",
		"",
		"切换次数到：0-次数未到，1-次数到",
		0,
		0,
		"次数到",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"OutputShort",
		"输出短路",
		"",
		"输出短路：0-未短路，1-短路",
		0,
		0,
		"短路",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"BatteryEOD",
		"电池EOD",
		"",
		"电池EOD：0-未EOD，1-电池EOD",
		0,
		0,
		"电池EOD",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"BatterySelfCheckStatus",
		"电池自检状态",
		"",
		"电池自检状态：0-未自检，1-成功，2-失败，3-自检中",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"BatteryMaintenanceStatus",
		"电池维护状态",
		"",
		"电池维护状态：0-未维护测试，1-成功，2-失败，3-维护测试中",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"BatteryLowVoltage",
		"电池低压",
		"",
		"电池低压：0-未低压，1-电池低压",
		0,
		0,
		"电池低压",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ReverseBattery",
		"电池反接",
		"",
		"电池反接：0-未反接，1-电池反接",
		0,
		0,
		"电池反接",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"RectifierStatus",
		"整流器状态",
		"",
		"整流器状态：0-关闭，1-软启动，2-正常工作",
		0,
		0,
		"关闭",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"InputNLineDisconnected",
		"输入N线断开",
		"",
		"输入N线断开：0-正常，1-断开",
		0,
		0,
		"断开",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"BypassFanFailure",
		"旁路风扇故障",
		"",
		"旁路风扇故障：0-正常，1-故障",
		0,
		0,
		"故障",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"LossNXRedundancy",
		"失去N+X冗余",
		"",
		"失去N+X冗余：0-未失去，1-失去",
		0,
		0,
		"失去",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"EODSystemInhibit",
		"EOD系统禁止",
		"",
		"EOD系统禁止：0-未禁止，1-禁止",
		0,
		0,
		"禁止",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ModuleRectifierFailure",
		"模块整流故障",
		"",
		"模块整流故障：0-正常，1-故障",
		0,
		0,
		"故障",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ModuleInverterFailure",
		"模块逆变故障",
		"",
		"模块逆变故障：0-正常，1-故障",
		0,
		0,
		"故障",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ModuleRectifierOverTemperature",
		"模块整流过温",
		"",
		"模块整流过温：0-正常，1-故障",
		0,
		0,
		"故障",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ModuleFanFailure",
		"模块风扇故障",
		"",
		"模块风扇故障：0-正常，1-故障",
		0,
		0,
		"故障",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ModuleInverterOverload",
		"模块逆变过载",
		"",
		"模块逆变过载：0-正常，1-故障",
		0,
		0,
		"故障",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ModuleInversionOverTemperature",
		"模块逆变过温",
		"",
		"模块逆变过温：0-正常，1-故障",
		0,
		0,
		"故障",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ModuleInverterProtection",
		"模块逆变保护",
		"",
		"模块逆变保护：0-正常，1-故障",
		0,
		0,
		"故障",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ModuleManualShutdown",
		"模块手动关机",
		"",
		"模块手动关机：0-正常，1-故障",
		0,
		0,
		"故障",
		"",
		0,
		0
	}
};


/**********************************************************************************************************
* 函数名称： static void cmd_fun(short index, int addr, void *data, char *cmd, short *len)
* 函数说明： 生成获取传感器数据指令
* 输入参数： 指令索引，传感器地址，变量结构体指针,以及指令缓存区指针,指令长度
* 返回参数： 无
**********************************************************************************************************/
static void cmd_fun(short index, int addr, void *data, char *cmd, short *len)
{
	switch(index)
	{
		case 0:
			cmd[0] = addr;
			cmd[1] = 0x03;
			cmd[2] = 0x00;								
			cmd[3] = 0x01;
			cmd[4] = 0x00;	
			cmd[5] = 0x38;
			*len = CRC16_Padding(cmd, 6);
			break;
		case 1:
			cmd[0] = addr;
			cmd[1] = 0x04;
			cmd[2] = 0x00;								
			cmd[3] = 0x51;
			cmd[4] = 0x00;	
			cmd[5] = 0x21;
			*len = CRC16_Padding(cmd, 6);
			break;
		case 2:
			cmd[0] = addr;
			cmd[1] = 0x04;
			cmd[2] = 0x00;								
			cmd[3] = 0x79;
			cmd[4] = 0x00;	
			cmd[5] = 0x76;
			*len = CRC16_Padding(cmd, 6);
			break;
		default:
			break;
	}
}


/**********************************************************************************************************
* 函数名称： static int parse_fun(short index, int addr, void *data, char *buffer, short len)
* 函数说明： 解析传感器响应的数据，并写入数据库
* 输入参数： 解析索引,传感器地址，变量结构体指针，以及响应数据缓存取指针，响应数据长度
* 返回参数： 返回解析结果，返回0成功，返回1失败
**********************************************************************************************************/
static int parse_fun(short index, int addr, void *data, char *buffer, short len)
{
	const char *PowerSupplyMode[]			= {"均不供电","UPS供电","旁路供电","未知"};
	const char *BatteryStatus[]				= {"电池未工作","电池浮充","电池均充","电池放电","未知"};
	const char *BatterySelfCheckStatus[]	= {"未自检","成功","失败","自检中","未知"};
	const char *BatteryMaintenanceStatus[]	= {"未维护测试","成功","失败","维护测试中","未知"};
	const char *RectifierStatus[]			= {"关闭","软启动","正常工作","未知"};
	
	union{
		unsigned short	dat16;
      	unsigned char  	dat8[2];
    }DAT16_8;						   //数据类型转换	
	Data_Struct	*d = (Data_Struct*)data;
	unsigned char  	*buf = (unsigned char*)buffer;
	unsigned char	i;
	if(buf!=NULL && buf[0]==addr && len>0)
	{	
		if(CRC16_Check((char*)buf,len))
		{
			switch(index)
			{
				case 0:
					DAT16_8.dat8[1] = buf[3];
					DAT16_8.dat8[0] = buf[4];
					d->BypassUA.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[5];
					DAT16_8.dat8[0] = buf[6];
					d->BypassUB.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[7];
					DAT16_8.dat8[0] = buf[8];
					d->BypassUC.value.fnum = DAT16_8.dat16*0.1;

					DAT16_8.dat8[1] = buf[9];
					DAT16_8.dat8[0] = buf[10];
					d->BypassIA.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[11];
					DAT16_8.dat8[0] = buf[12];
					d->BypassIB.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[13];
					DAT16_8.dat8[0] = buf[14];
					d->BypassIC.value.fnum = DAT16_8.dat16*0.1;

					DAT16_8.dat8[1] = buf[15];
					DAT16_8.dat8[0] = buf[16];
					d->BypassFreqA.value.fnum = DAT16_8.dat16*0.01;
					DAT16_8.dat8[1] = buf[17];
					DAT16_8.dat8[0] = buf[18];
					d->BypassFreqB.value.fnum = DAT16_8.dat16*0.01;
					DAT16_8.dat8[1] = buf[19];
					DAT16_8.dat8[0] = buf[20];
					d->BypassFreqC.value.fnum = DAT16_8.dat16*0.01;

					DAT16_8.dat8[1] = buf[21];
					DAT16_8.dat8[0] = buf[22];
					d->BypassCOSA.value.fnum = DAT16_8.dat16*0.01;
					DAT16_8.dat8[1] = buf[23];
					DAT16_8.dat8[0] = buf[24];
					d->BypassCOSB.value.fnum = DAT16_8.dat16*0.01;
					DAT16_8.dat8[1] = buf[25];
					DAT16_8.dat8[0] = buf[26];
					d->BypassCOSC.value.fnum = DAT16_8.dat16*0.01;

					DAT16_8.dat8[1] = buf[27];
					DAT16_8.dat8[0] = buf[28];
					d->InputUA.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[29];
					DAT16_8.dat8[0] = buf[30];
					d->InputUB.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[31];
					DAT16_8.dat8[0] = buf[32];
					d->InputUC.value.fnum = DAT16_8.dat16*0.1;

					DAT16_8.dat8[1] = buf[33];
					DAT16_8.dat8[0] = buf[34];
					d->InputIA.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[35];
					DAT16_8.dat8[0] = buf[36];
					d->InputIB.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[37];
					DAT16_8.dat8[0] = buf[38];
					d->InputIC.value.fnum = DAT16_8.dat16*0.1;

					DAT16_8.dat8[1] = buf[39];
					DAT16_8.dat8[0] = buf[40];
					d->InputFreqA.value.fnum = DAT16_8.dat16*0.01;
					DAT16_8.dat8[1] = buf[41];
					DAT16_8.dat8[0] = buf[42];
					d->InputFreqB.value.fnum = DAT16_8.dat16*0.01;
					DAT16_8.dat8[1] = buf[43];
					DAT16_8.dat8[0] = buf[44];
					d->InputFreqC.value.fnum = DAT16_8.dat16*0.01;

					DAT16_8.dat8[1] = buf[45];
					DAT16_8.dat8[0] = buf[46];
					d->InputCOSA.value.fnum = DAT16_8.dat16*0.01;
					DAT16_8.dat8[1] = buf[47];
					DAT16_8.dat8[0] = buf[48];
					d->InputCOSB.value.fnum = DAT16_8.dat16*0.01;
					DAT16_8.dat8[1] = buf[49];
					DAT16_8.dat8[0] = buf[50];
					d->InputCOSC.value.fnum = DAT16_8.dat16*0.01;

					DAT16_8.dat8[1] = buf[51];
					DAT16_8.dat8[0] = buf[52];
					d->OutputUA.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[53];
					DAT16_8.dat8[0] = buf[54];
					d->OutputUB.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[55];
					DAT16_8.dat8[0] = buf[56];
					d->OutputUC.value.fnum = DAT16_8.dat16*0.1;

					DAT16_8.dat8[1] = buf[57];
					DAT16_8.dat8[0] = buf[58];
					d->OutputIA.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[59];
					DAT16_8.dat8[0] = buf[60];
					d->OutputIB.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[61];
					DAT16_8.dat8[0] = buf[62];
					d->OutputIC.value.fnum = DAT16_8.dat16*0.1;

					DAT16_8.dat8[1] = buf[63];
					DAT16_8.dat8[0] = buf[64];
					d->OutputFreqA.value.fnum = DAT16_8.dat16*0.01;
					DAT16_8.dat8[1] = buf[65];
					DAT16_8.dat8[0] = buf[66];
					d->OutputFreqB.value.fnum = DAT16_8.dat16*0.01;
					DAT16_8.dat8[1] = buf[67];
					DAT16_8.dat8[0] = buf[68];
					d->OutputFreqC.value.fnum = DAT16_8.dat16*0.01;

					DAT16_8.dat8[1] = buf[69];
					DAT16_8.dat8[0] = buf[70];
					d->OutputCOSA.value.fnum = DAT16_8.dat16*0.01;
					DAT16_8.dat8[1] = buf[71];
					DAT16_8.dat8[0] = buf[72];
					d->OutputCOSB.value.fnum = DAT16_8.dat16*0.01;
					DAT16_8.dat8[1] = buf[73];
					DAT16_8.dat8[0] = buf[74];
					d->OutputCOSC.value.fnum = DAT16_8.dat16*0.01;

					DAT16_8.dat8[1] = buf[75];
					DAT16_8.dat8[0] = buf[76];
					d->OutputSA.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[77];
					DAT16_8.dat8[0] = buf[78];
					d->OutputSB.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[79];
					DAT16_8.dat8[0] = buf[80];
					d->OutputSC.value.fnum = DAT16_8.dat16*0.1;

					DAT16_8.dat8[1] = buf[81];
					DAT16_8.dat8[0] = buf[82];
					d->OutputPA.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[83];
					DAT16_8.dat8[0] = buf[84];
					d->OutputPB.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[85];
					DAT16_8.dat8[0] = buf[86];
					d->OutputPC.value.fnum = DAT16_8.dat16*0.1;

					DAT16_8.dat8[1] = buf[87];
					DAT16_8.dat8[0] = buf[88];
					d->OutputQA.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[89];
					DAT16_8.dat8[0] = buf[90];
					d->OutputQB.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[91];
					DAT16_8.dat8[0] = buf[92];
					d->OutputQC.value.fnum = DAT16_8.dat16*0.1;

					DAT16_8.dat8[1] = buf[93];
					DAT16_8.dat8[0] = buf[94];
					d->OutputLoadRateA.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[95];
					DAT16_8.dat8[0] = buf[96];
					d->OutputLoadRateB.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[97];
					DAT16_8.dat8[0] = buf[98];
					d->OutputLoadRateC.value.fnum = DAT16_8.dat16*0.1;

					DAT16_8.dat8[1] = buf[99];
					DAT16_8.dat8[0] = buf[100];
					d->AmbientTemperature.value.fnum = DAT16_8.dat16*0.1;
					
					DAT16_8.dat8[1] = buf[101];
					DAT16_8.dat8[0] = buf[102];
					d->PositiveBatteryVoltage.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[103];
					DAT16_8.dat8[0] = buf[104];
					d->NegativeBatteryVoltage.value.fnum = DAT16_8.dat16*0.1;
					
					DAT16_8.dat8[1] = buf[105];
					DAT16_8.dat8[0] = buf[106];
					d->PositiveBatteryCurrent.value.fnum = ((short)DAT16_8.dat16)*0.1;	
					DAT16_8.dat8[1] = buf[107];
					DAT16_8.dat8[0] = buf[108];
					d->NegativeBatteryCurrent.value.fnum = ((short)DAT16_8.dat16)*0.1;

					DAT16_8.dat8[1] = buf[109];
					DAT16_8.dat8[0] = buf[110];
					d->BatteryTemperature.value.fnum = DAT16_8.dat16*0.1;	
					DAT16_8.dat8[1] = buf[111];
					DAT16_8.dat8[0] = buf[112];
					d->BatteryRemainingTime.value.fnum = DAT16_8.dat16*0.1;	
					DAT16_8.dat8[1] = buf[113];
					DAT16_8.dat8[0] = buf[114];
					d->BatteryCapacity.value.fnum = DAT16_8.dat16*0.1;
					break;
				case 1:
					d->PowerSupplyMode.value.str							= PowerSupplyMode[buf[4]<3?buf[4]:3];
					Set_Var_Status(&d->PowerSupplyMode,						  buf[4]==0?Alarm:Normal, NULL);

					d->BatteryStatus.value.str								= BatteryStatus[buf[6]<4?buf[6]:4];
					Set_Var_Status(&d->BatteryStatus,						  (buf[6]==3||buf[6]==0)?Alarm:Normal, NULL);
					
					d->MaintenanceBypassAirSwitchStatus.value.str			= buf[10]?"闭合":"断开";
					Set_Var_Status(&d->MaintenanceBypassAirSwitchStatus,	  buf[10]?Alarm:Normal, NULL);

					d->EPO.value.str										= buf[12]?"紧急关机":"无紧急关机";
					Set_Var_Status(&d->EPO,									  buf[12]?Alarm:Normal, NULL);

					d->InsufficientStartingCapacity.value.str				= buf[14]?"容量不足":"容量足够";
					Set_Var_Status(&d->InsufficientStartingCapacity,		  buf[14]?Alarm:Normal, NULL);

					d->GeneratorJoin.value.str								= buf[16]?"接入":"断开";
					Set_Var_Status(&d->GeneratorJoin,						  buf[16]?Alarm:Normal, NULL);

					d->ACInputFailure.value.str								= buf[18]?"故障":"正常";
					Set_Var_Status(&d->ACInputFailure,						  buf[18]?Alarm:Normal, NULL);

					d->BypassPhaseSequenceFault.value.str					= buf[20]?"故障":"正常";
					Set_Var_Status(&d->BypassPhaseSequenceFault,			  buf[20]?Alarm:Normal, NULL);

					d->BypassVoltageFailure.value.str						= buf[22]?"故障":"正常";
					Set_Var_Status(&d->BypassVoltageFailure,				  buf[22]?Alarm:Normal, NULL);

					d->BypassFailure.value.str								= buf[24]?"故障":"正常";
					Set_Var_Status(&d->BypassFailure,						  buf[24]?Alarm:Normal, NULL);

					d->BypassOverload.value.str								= buf[26]?"过载":"正常";
					Set_Var_Status(&d->BypassOverload,						  buf[26]?Alarm:Normal, NULL);

					d->BypassOverloadTimeout.value.str						= buf[28]?"过载超时":"正常";
					Set_Var_Status(&d->BypassOverloadTimeout,				  buf[28]?Alarm:Normal, NULL);

					d->BypassOvertrack.value.str							= buf[30]?"旁路超跟踪":"正常";
					Set_Var_Status(&d->BypassOvertrack,						  buf[30]?Alarm:Normal, NULL);

					d->SwitchTimesTo.value.str								= buf[32]?"次数到":"次数未到";
					Set_Var_Status(&d->SwitchTimesTo,						  buf[32]?Alarm:Normal, NULL);

					d->OutputShort.value.str								= buf[34]?"短路":"未短路";
					Set_Var_Status(&d->OutputShort,							  buf[34]?Alarm:Normal, NULL);

					d->BatteryEOD.value.str									= buf[36]?"电池EOD":"未EOD";
					Set_Var_Status(&d->BatteryEOD,							  buf[36]?Alarm:Normal, NULL);

					d->BatterySelfCheckStatus.value.str						= BatterySelfCheckStatus[buf[40]<4?buf[40]:4];
					Set_Var_Status(&d->BatterySelfCheckStatus,				  buf[40]==2?Alarm:Normal, NULL);

					d->BatteryMaintenanceStatus.value.str					= BatteryMaintenanceStatus[buf[44]<4?buf[44]:4];
					Set_Var_Status(&d->BatteryMaintenanceStatus,			  buf[44]==2?Alarm:Normal, NULL);

					d->BatteryLowVoltage.value.str							= buf[56]?"电池低压":"未低压";
					Set_Var_Status(&d->BatteryLowVoltage,					  buf[56]?Alarm:Normal, NULL);

					d->ReverseBattery.value.str								= buf[58]?"电池反接":"未反接";
					Set_Var_Status(&d->ReverseBattery,						  buf[58]?Alarm:Normal, NULL);

					d->RectifierStatus.value.str							= RectifierStatus[buf[60]<3?buf[60]:3];
					Set_Var_Status(&d->RectifierStatus,						  buf[60]==0?Alarm:Normal, NULL);

					d->InputNLineDisconnected.value.str						= buf[62]?"断开":"正常";
					Set_Var_Status(&d->InputNLineDisconnected,				  buf[62]?Alarm:Normal, NULL);

					d->BypassFanFailure.value.str							= buf[64]?"故障":"正常";
					Set_Var_Status(&d->BypassFanFailure,					  buf[64]?Alarm:Normal, NULL);

					d->LossNXRedundancy.value.str							= buf[66]?"失去":"未失去";
					Set_Var_Status(&d->LossNXRedundancy,					  buf[66]?Alarm:Normal, NULL);

					d->EODSystemInhibit.value.str							= buf[68]?"禁止":"未禁止";
					Set_Var_Status(&d->EODSystemInhibit,					  buf[68]?Alarm:Normal, NULL);
					break;
				case 2:
					i = 6;
					if(buf[i]||buf[i+24]||buf[i+48]||buf[i+72]||buf[i+96]||buf[i+120]||buf[i+144]||buf[i+168]||buf[i+192]||buf[i+216]){
						d->ModuleRectifierFailure.value.str					= "故障";
						Set_Var_Status(&d->ModuleRectifierFailure,			Alarm, NULL);	
					}
					else{
						d->ModuleRectifierFailure.value.str					= "正常";
						Set_Var_Status(&d->ModuleRectifierFailure,			Normal, NULL);
					}
					i = 8;
					if(buf[i]||buf[i+24]||buf[i+48]||buf[i+72]||buf[i+96]||buf[i+120]||buf[i+144]||buf[i+168]||buf[i+192]||buf[i+216]){
						d->ModuleInverterFailure.value.str					= "故障";
						Set_Var_Status(&d->ModuleInverterFailure,			Alarm, NULL);	
					}
					else{
						d->ModuleInverterFailure.value.str					= "正常";
						Set_Var_Status(&d->ModuleInverterFailure,			Normal, NULL);
					}					
					i = 10;
					if(buf[i]||buf[i+24]||buf[i+48]||buf[i+72]||buf[i+96]||buf[i+120]||buf[i+144]||buf[i+168]||buf[i+192]||buf[i+216]){
						d->ModuleRectifierOverTemperature.value.str			= "故障";
						Set_Var_Status(&d->ModuleRectifierOverTemperature,	Alarm, NULL);	
					}
					else{
						d->ModuleRectifierOverTemperature.value.str			= "正常";
						Set_Var_Status(&d->ModuleRectifierOverTemperature,	Normal, NULL);
					}					
					i = 12;
					if(buf[i]||buf[i+24]||buf[i+48]||buf[i+72]||buf[i+96]||buf[i+120]||buf[i+144]||buf[i+168]||buf[i+192]||buf[i+216]){
						d->ModuleFanFailure.value.str						= "故障";
						Set_Var_Status(&d->ModuleFanFailure,				Alarm, NULL);	
					}
					else{
						d->ModuleFanFailure.value.str						= "正常";
						Set_Var_Status(&d->ModuleFanFailure,				Normal, NULL);
					}
					i = 14;
					if(buf[i]||buf[i+24]||buf[i+48]||buf[i+72]||buf[i+96]||buf[i+120]||buf[i+144]||buf[i+168]||buf[i+192]||buf[i+216]){
						d->ModuleInverterOverload.value.str					= "故障";
						Set_Var_Status(&d->ModuleInverterOverload,			Alarm, NULL);	
					}
					else{
						d->ModuleInverterOverload.value.str					= "正常";
						Set_Var_Status(&d->ModuleInverterOverload,			Normal, NULL);
					}
					i = 16;
					if(buf[i]||buf[i+24]||buf[i+48]||buf[i+72]||buf[i+96]||buf[i+120]||buf[i+144]||buf[i+168]||buf[i+192]||buf[i+216]){
						d->ModuleInversionOverTemperature.value.str			= "故障";
						Set_Var_Status(&d->ModuleInversionOverTemperature,	Alarm, NULL);	
					}
					else{
						d->ModuleInversionOverTemperature.value.str			= "正常";
						Set_Var_Status(&d->ModuleInversionOverTemperature,	Normal, NULL);
					}
					i = 18;
					if(buf[i]||buf[i+24]||buf[i+48]||buf[i+72]||buf[i+96]||buf[i+120]||buf[i+144]||buf[i+168]||buf[i+192]||buf[i+216]){
						d->ModuleInverterProtection.value.str				= "故障";
						Set_Var_Status(&d->ModuleInverterProtection,		Alarm, NULL);	
					}
					else{
						d->ModuleInverterProtection.value.str				= "正常";
						Set_Var_Status(&d->ModuleInverterProtection,		Normal, NULL);
					}
					i = 20;
					if(buf[i]||buf[i+24]||buf[i+48]||buf[i+72]||buf[i+96]||buf[i+120]||buf[i+144]||buf[i+168]||buf[i+192]||buf[i+216]){
						d->ModuleManualShutdown.value.str					= "故障";
						Set_Var_Status(&d->ModuleManualShutdown,			Alarm, NULL);	
					}
					else{
						d->ModuleManualShutdown.value.str					= "正常";
						Set_Var_Status(&d->ModuleManualShutdown,			Normal, NULL);
					}
					break;				
				default:
					break;
			}
			return 0;
		}
	}
	return 1;
}


/**********************************************************************************************************
* 函数名称： void ups_INVT33_Registration(void)
* 函数说明： UPS监测驱动注册
* 输入参数： 无
* 返回参数： 无
**********************************************************************************************************/
void ups_INVT33_Registration(void)
{
	DeviceRegWithResTimeout(
		"ups",													//设备类型
		"UPS监测",												//设备名称（导航栏默认显示名称）
		"INVT33",												//设备型号
		"适用于英威腾三进三出UPS电源状态和报警监测。",					//驱动描述
		var_attr,												//变量属性声明
		sizeof(Data_Struct),									//变量结构体空间大小
		cmd_fun,												//发送指令生成函数
		parse_fun,												//数据解析函数
		600														//设备响应超时时间
	);
#if 0
	#define CMD1 "\x01\x03\x00\x01\x00\x38\x15\xD8"
	#define RSP1 "\x01\x03\x70\x08\x8B\x08\xC4\x08\xA9\x00\x00\x00\x00\x00\x00\x13\x84\x13\x84\x13\x84\x00\x64\x00\x64\x00\x64\x08\x82\x08\xBC\x08\xA7\x00\x02\x00\x03\x00\x05\x13\x84\x13\x84\x13\x85\x00\x0D\x00\x0F\x00\x0F\x08\xA1\x08\xA3\x08\x9E\x00\x06\x00\x06\x00\x05\x13\x84\x13\x84\x13\x84\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFA\x0A\x85\x0A\x91\x00\x00\x00\x00\x00\xFA\x7F\xF8\x03\xE8\x40\x03"
	#define CMD2 "\x01\x04\x00\x51\x00\x21\x61\xC3"		
	#define RSP2 "\x01\x04\x42\x00\x01\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x5F\xBB"
	#define CMD3 "\x01\x04\x00\x79\x00\x76\xA0\x35"
	#define RSP3 "\x01\x04\xEC\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7C\x6D"				
		
	VirtualFrameRegistration(CMD1, sizeof(CMD1)-1, RSP1, sizeof(RSP1)-1);
	VirtualFrameRegistration(CMD2, sizeof(CMD2)-1, RSP2, sizeof(RSP2)-1);
	VirtualFrameRegistration(CMD3, sizeof(CMD3)-1, RSP3, sizeof(RSP3)-1);
#endif	
}

